package lc_2785_将字符串中的元音字母排序;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Solution {

    public String sortVowels(String s) {
        char[] array = s.toCharArray();
        List<Character> list = new ArrayList<>();
        for (int i = 0; i < s.length(); i++) {
            if ("aeiouAEIOU".indexOf(String.valueOf(array[i])) > -1) {
                list.add(array[i]);
            }
        }
        Collections.sort(list);
        for (int i = 0, j = 0; i < s.length(); i++) {
            if ("aeiouAEIOU".indexOf(String.valueOf(array[i])) > -1) {
                array[i] = list.get(j++);
            }
        }
        return new String(array);
    }
}